This section describes a number of simple operations on lists, i.e., chains of cons cells.
This function is equivalent to
(car (cdr (cdrx))). Likewise, this package defines all 28cxxxrfunctions where xxx is up to four ‘a’s and/or ‘d’s. All of these functions aresetf-able, and calls to them are expanded inline by the byte-compiler for maximum efficiency.
This function is a synonym for
(carx). Likewise, the functionssecond,third, ..., throughtenthreturn the given element of the list x.
Common Lisp defines this function to act like
null, but signaling an error ifxis neither anilnor a cons cell. This package simply definesendpas a synonym fornull.
This function returns the length of list x, exactly like
(lengthx), except that if x is a circular list (where the cdr-chain forms a loop rather than terminating withnil), this function returnsnil. (The regularlengthfunction would get stuck if given a circular list.)
This function constructs a list of its arguments. The final argument becomes the
cdrof the last cell constructed. Thus,(list*a b c)is equivalent to(consa(consb c)), and(list*a bnil)is equivalent to(lista b).(Note that this function really is called
list*in Common Lisp; it is not a name invented for this package likemember*ordefun*.)
If sublist is a sublist of list, i.e., is
eqto one of the cons cells of list, then this function returns a copy of the part of list up to but not including sublist. For example,(ldiff x (cddr x))returns the first two elements of the listx. The result is a copy; the original list is not modified. If sublist is not a sublist of list, a copy of the entire list is returned.
This function returns a copy of the list list. It copies dotted lists like
(1 2 . 3)correctly.
This function returns a copy of the tree of cons cells x. Unlike
copy-sequence(and its aliascopy-list), which copies only along thecdrdirection, this function copies (recursively) along both thecarand thecdrdirections. If x is not a cons cell, the function simply returns x unchanged. If the optional vecp argument is true, this function copies vectors (recursively) as well as cons cells.
This function compares two trees of cons cells. If x and y are both cons cells, their
cars andcdrs are compared recursively. If neither x nor y is a cons cell, they are compared byeql, or according to the specified test. The:keyfunction, if specified, is applied to the elements of both trees. See Sequences.